package com.wey.thread;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CallableCase {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable myCallable = new MyCallable();
        FutureTask<Integer> futureTask = new FutureTask<>(myCallable);
        Thread thread = new Thread(futureTask);
//        thread.setName("MyCallable_1");
        thread.start();
        Integer integer = futureTask.get();

        MyCallable myCallable2 = new MyCallable();
        FutureTask<Integer> futureTask2 = new FutureTask<>(myCallable2);
        Thread thread2 = new Thread(futureTask2);
//        thread2.setName("MyCallable_2");
        thread2.start();
        Integer integer2 = futureTask2.get();
        System.out.println(integer);
        System.out.println(integer2);
    }
}
